package com.example.demo.controller;

import com.example.demo.annotation.Roles;
import com.example.demo.dto.ElderlyBasicAddDTO;
import com.example.demo.dto.ElderlyDetailedAddDTO;
import com.example.demo.dto.ElderlyDetailedPageDTO;
import com.example.demo.pojo.ElderlyDetailed;
import com.example.demo.pojo.Result;
import com.example.demo.service.ElderlyBasicService;
import com.example.demo.service.ElderlyDetailedService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("elderly/detailed")
@Slf4j
@Tag(name = "老人接口")
@RequiredArgsConstructor
public class ElderlyDetailedController {
    private final ElderlyDetailedService elderlyDetailedService;
    @PostMapping
    @Operation(summary = "添加未确认详细数据")
    @Roles(values = "ru")
    public Result addElderlyDetail(@RequestBody ElderlyDetailedAddDTO elderlyDetailedAddDTO) {
        elderlyDetailedService.addElderlyDetail(elderlyDetailedAddDTO);
        return Result.success();
    }
    @GetMapping
    @Operation(summary = "查看未确认详细数据")
    @Roles(values = "da")
    public Result<List<ElderlyDetailed>> getElderlyDetail(ElderlyDetailedPageDTO elderlyDetailedPageDTO) {
        List<ElderlyDetailed> elderlyDetailedList = elderlyDetailedService.getElderlyDetail(elderlyDetailedPageDTO);
        return Result.success(elderlyDetailedList);
    }
}
